<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta content="yes" name="apple-mobile-web-app-capable">
	<meta content="yes" name="apple-touch-fullscreen">
	<meta content="telephone=no,email=no" name="format-detection">
	<!--防止css、js资源缓存-->
	<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
	<meta http-equiv="Pragma" content="no-cache" />
	<meta http-equiv="Expires" content="0" />
	<script type="text/javascript" src="asserts/resource/js/flexible_C.js" ></script>
	<title>历史轨迹</title>
	<link rel="stylesheet" href="asserts/resource/css/common.css">
	<link rel="stylesheet" href="asserts/resource/css/css.css">
	<link rel="stylesheet" href="asserts/resource/LCalendar/css/LCalendar.css" />
</head>
<body class="hrbody">
<div class="HR-content">
	<div class="HR-tab">
		<div><i class="TabIconY"></i><span data-day="J">今天</span></div>
		<div><i class="TabIconN"></i><span data-day="Z">昨天</span></div>
		<div><i class="TabIconN"></i><span data-day="S">自定义</span></div>
	</div>
	<div class="HrTab-time"><!--点击两个div分别弹出日期选择-->
		<div class="starttime">
			<p class="dateLocation"><i class="DLIcon"></i>
				<input type="text" name="start_date" id="start_date" disabled="disabled" readonly="readonly" placeholder=""/>
			</p>
			<p class="timeLocation"><i class="TLIcon"></i>
				<input type="text" name="start_time" id="start_time" disabled="disabled" readonly="readonly" />
			</p>
		</div>
		<div class="endtime">
			<p class="dateLocation"><i class="DLIcon"></i>
				<input type="text" name="end_date" id="end_date" disabled="disabled" readonly="readonly" />
			</p>
			<p class="timeLocation"><i class="TLIcon"></i>
				<input type="text" name="end_time" id="end_time" disabled="disabled" readonly="readonly" />
			</p>
		</div>
		<div id="text_tip" style="display:none;margin-top:15px;">
			<span>请搜索一天范围内的历史轨迹</span>
		</div>
	</div>
	<p class="ShowPosition">
		<i class="TabIconN" data-status="0"></i><span>显示LBS定位地点</span>
	</p>
</div>
<div class="HRbuttonWrap">
	<a href="javascript:void(0);" class="HRbutton" id='route' target="_blank">搜索</a>
</div>
</body>
<script type="text/javascript" src="asserts/resource/js/jquery.min.js"></script>
<script type="text/javascript" src="asserts/resource/layer/mobile/layer.js"></script>
<script type="text/javascript" src="asserts/resource/LCalendar/js/format.js"></script>
<script type="text/javascript" src="asserts/resource/LCalendar/js/LCalendar.js"></script>
<script type="text/javascript" src="asserts/resource/js/js.js"></script>
<script>
    //绑定时间插件
    var calendar1 = new LCalendar();
    calendar1.init({
        'trigger': '#start_date', //标签id
        'type': 'date', //date 调出日期选择 datetime 调出日期时间选择 time 调出时间选择 ym 调出年月选择,
        'minDate': (new Date().getFullYear()-3) + '-' + 1 + '-' + 1, //最小日期
        'maxDate': (new Date().getFullYear()+3) + '-' + 12 + '-' + 31 //最大日期
    });
    // var calendar2 = new LCalendar();
    // calendar2.init({
    //     'trigger': '#end_date',
    //     'type': 'date',
    //     'minDate': (new Date().getFullYear()-3) + '-' + 1 + '-' + 1,
    //     'maxDate': (new Date().getFullYear()+3) + '-' + 12 + '-' + 31
    // });
    var calendar3 = new LCalendar();
    calendar3.init({
        'trigger': '#start_time',
        'type': 'time',
    });
    var calendar4 = new LCalendar();
    calendar4.init({
        'trigger': '#end_time',
        'type': 'time',
    });

    var start_date_val,start_time_val,end_date_val,end_time_val,lbsStatus;
    var dateObj={},dateJson;
    $("#route").click(function(){
        start_date_val = $("#start_date").val();
        start_time_val = $("#start_time").val();
        end_date_val = $("#end_date").val();
        end_time_val = $("#end_time").val();
		lbsStatus = $(".ShowPosition").find("i").attr("data-status");
        dateObj.startTime = start_date_val+' '+start_time_val;
        dateObj.endTime = end_date_val+' '+end_time_val;
        dateObj.lbsStatus = lbsStatus;
        dateJson = JSON.stringify(dateObj);
        localStorage.dateJson = dateJson;
        if(dateObj.startTime>= dateObj.endTime){
            layerMsg('时间区间选择有误',2);
            return;
        }
        getData(dateObj.startTime,dateObj.endTime, dateObj.lbsStatus);
    });

	//查询是否有轨迹信息
    function getData(startTime,endTime,locationType) {
        $.ajax({
            //几个参数需要注意一下
            type: "POST",//方法类型
            async: false, // 使用同步方式
            dataType: "json",//预期服务器返回的数据类型
            url: "/position/history" ,//url
            data: {"startTime":startTime,"endTime":endTime,"locationType":locationType},
            success: function (result) {
                var data= result.data;
                if (result.status == 1) {
                   if(data.length>0){
                       window.location.href='HistoricalMap.html';
				   }else {
                       layerMsg('该时间区间无轨迹信息,请重新选择!',2);
				   }
                }else{
                    layerMsg(result.msg,2);
                }
            },
            error : function() {
                layerMsg('网络异常!',2);
            }
        });
    }

</script>
</html>
